<!DOCTYPE html>
<html lang="en">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
		<meta name="description" content="">
		<meta name="author" content="">
		<!-- STYLESHEETS -->
		<!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
		<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
		<link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
		<link rel="stylesheet" type="text/css" href="../../css/responsive.css">

		<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
		<!-- file-input -->
		<link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
		<!-- SELECT2 -->
		<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />
		<!-- UNIFORM -->
		<link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css" />
		<!-- datatable -->
		<link rel="stylesheet" href="../../js/datatables/datatable.css">
		<!-- WIZARD -->
		<link rel="stylesheet" type="text/css" href="../../js/bootstrap-wizard/wizard.css" />
		  <link rel="stylesheet" href="../../js/datepicker/datepicker.css">
		<!-- FONTS
	<link href='http://fonts.useso.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'>
-->
	
	</head>

	<body>
		<header class="navbar clearfix" id="header">
		</header>
		<!-- PAGE -->
		<section id="page">
			<!-- SIDEBAR -->
			<div id="sidebar" class="sidebar">
				<div class="sidebar-menu nav-collapse">
					<!-- SIDEBAR MENU -->
					<ul>

					</ul>
					<!-- /SIDEBAR MENU -->
				</div>
			</div>
			<!-- /SIDEBAR -->
			<div id="main-content">
				<div class="container">
					<div class="row">
						<div id="content" class="col-lg-12">
							<!-- PAGE HEADER-->
							<div class="row">
								<div class="col-sm-12">
									<div class="page-header">
										<!-- STYLER -->

										<!-- /STYLER -->
										<!-- BREADCRUMBS -->
										<ul class="breadcrumb">
											<li>
												<i class="fa fa-home"></i>
												<a href="index.html">首页</a>
											</li>
											<li>
												<a href="#">媒体管理</a>
											</li>
											<li>上传媒体图片</li>
										</ul>
										<!-- /BREADCRUMBS -->

									</div>
								</div>
							</div>
							<!-- /PAGE HEADER -->
							<!-- SAMPLE -->
							<form id="form_coupon">
								<div class="row col-md-12 uploadMainImage">
									<div class="col-md-2" style="width: 25%;">
										<div class="" style="text-align: center;margin-top:20%;font-size:24px;">上传图片</div>
									</div>
									<div class="col-md-9" style="line-height:34px;display:inline">
									<div class="row" style="height: 30px;">
									<div class="col-md-12" style="text-align: center;">
									</div>
							    </div>
										<div class="box border primary">
											<div style="overflow: hidden;padding:30px 0 0px 17px;">
												<label class="col-sm-1 control-label" for="e1" style="width: 102px">选择类型：</label>
													<div class="col-sm-2">
															<select id="status_select" name="orderStatus" class="col-md-12 select2-offscreen" tabindex="-1">
															   <option value="CusQrCode">客服二维码</option>
															   <option value="FansQrCode">粉丝群二维码</option>
															</select>												
													</div>
												<div id="upload1" class="addnewimg" style="float:left; margin-left:5px;">
													<span id="fir" class="btn btn-success btn-file">
														<span id="uploadimg" class="fileinput-new">上传图片</span>
														<input type="file" upload-file="imageUrlProduct" multiple="" name="uploadFile">
													</span>
												</div>
												<div style="margin-top: 10px;width: 100px" aria-valuemax="100" aria-valuemin="0" role="progressbar" class="progress progress-striped active">
													<div style="width:0%;" class="progress-bar progress-bar-success"></div>
												</div>
											</div>
											<div class="mrg-bt10" style="overflow: hidden;">
												<div id="nestable2">
													<ol class="dd-list" style="display: block;padding-left:20px;overflow: hidden;">
														
													</ol>
												</div>
											</div>
										</div>
									</div>

								</div>
							</form>
							<!-- /SAMPLE -->

							<div class="footer-tools">
								<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
							</div>
						</div>
						<!-- /CONTENT-->
					</div>
				</div>
			</div>
		</section>
		<!--/PAGE -->
		<!-- JAVASCRIPTS -->
		<!-- Placed at the end of the document so the pages load faster -->
	    <!-- JQUERY -->
		<script src="../../js/jquery/jquery-2.0.3.min.js"></script>
		<script src="../../js/common.js"></script>
		<script src="../../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
		<!-- BOOTSTRAP -->
		<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
		<!-- SLIMSCROLL -->
		<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/jquery.slimscroll.min.js"></script>
		<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/slimScrollHorizontal.min.js"></script>
		<!-- BLOCK UI -->
		<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
		<!--bootbox-->
		<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
		<!-- AUTOSIZE -->
		<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
		<!-- spinner -->
		<script src="../../js/spinner/spin.js"></script>
		<!-- bootstrap-fileupload -->
		<script type="text/javascript" src="../../js/jquery-upload/js/jquery.iframe-transport.js"></script>
		<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload.min.js"></script>
		<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-process.min.js"></script>
		<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-validate.min.js"></script>
		<!-- INPUT MASK -->
		<script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
		<!-- SELECT2 -->
		<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
		<!-- UNIFORM -->
		<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
		<!-- WIZARD -->
		<script src="../../js/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
		<!-- WIZARD -->
		<script src="../../js/jquery-validate/jquery.validate.min.js"></script>
		<script src="../../js/jquery-validate/additional-methods.min.js"></script>
		<script src="../../js/bootstrap-wizard/form-wizard.js"></script>
		<!-- NESTABLE LISTS -->
		<script type="text/javascript" src="../../js/nestable/jquery.nestable.min.js"></script>
		<!-- COOKIE -->
		<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
		<!-- CUSTOM SCRIPT -->
		<script src="../../js/script.js"></script>
		<script src="../../js/Sortable.min.js"></script>
		<script>
			var AddCoupon = function(){
				var id=null,flag;
				var wizform = $('#form_coupon');
				var supplierid=$.getUrlParam('id');//判断是否有id  有id编辑  没id新增
				var flag=$.getUrlParam('flag');
				var img={};
				
				//上传商品图片
				var fileUpLoad = function() {
					$(".uploadMainImage").find('.progress-bar').css('width','0%');
					$(".uploadMainImage").find('.progress').hide();
					
					
					$("[upload-file=imageUrlProduct]").fileupload({//fileupload 插件方法
						url: App.getContextPath() + "admin/template/uploadMedia.do",
					  	add: function (e, data) {
						          //  data.imgType = $("[upload-file=imageUrlProduct]").click(function () {
						              var  selImg = $("#status_select").val();
						                    data.submit();
						           //});
						        },
						dataType: 'json',
						acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
						iframe: true,
						maxNumberOfFiles: 5,
						autoUpload: true,
						start:function(e) {		    	
					    	$(".uploadMainImage").find('.progress').fadeIn(300);					    	
					    	return true;
				    	},				
						done: function(e, data) {
							var result = data.result;		
							console.log(data)
							//alert(result);
					      //  addMainImageHtml(result.fileUrl,"");
					        $('#nestable2').nestable({maxDepth: 1});
						},						
					    progressall: function (e, data) {					    	
				            var progress = parseInt(data.loaded / data.total * 100, 10);
				           $(".uploadMainImage").find('.progress-bar').css('width',progress + '%');
				        }
					}).on('fileuploaddone',function(e,data) {
							$(".uploadMainImage").find(".progress").fadeOut(300);
					
					});
				};

				//添加商品主图
				var addMainImageHtml=function(url,id){
					var i="imgage"+($(".dd-list").find("li").length+1);
					var imgs='<li class="dd-item filter-content" style="float:left;margin-bottom:0;" data-id="'+i+'"><img class="dd-handle" width="180px" height="180px" src="'+url+'" pid="'+id+'"/>'+
						'<div class="hover-content"><a class="btn btn-danger hover-link colorbox-button btn-del-image"  title="删除"><i class="fa fa-times fa-1x"></i></a></div></li>';
					$(".dd-list").append(imgs);
					
					handleHover();
					$(".btn-setMain").unbind("click").bind("click",function(){
					 //已经设置主图的取消设置
					    $(".bt-main").hide();
					    $(this).prev().show();
					    $(this).hide();
					    $(this).next().hide();
					 });
					$(".btn-del-image").click(function(){
					    $(this).closest("li").remove();
					    $("#upload1").show();
					});
					  
					  //如果当前图片个数已经达到5个隐藏上传按钮
					  if($(".dd-list li").length==5)
					  {
					     $("#upload1").hide();
					  }
				};

				//设置主图或者删除
				var handleHover=function(){
					$('.filter-content').hover(function() {
						var hoverContent = $(this).children('.hover-content');
						hoverContent.removeClass('fadeOut').addClass('animated fadeIn').show();

						if(flag=="1"){
							hoverContent.hide();
						}

					}, function(){
						var hoverContent = $(this).children('.hover-content');
						hoverContent.removeClass('fadeIn').addClass('fadeOut').hide();
					});
					
				};

				return {
					init: function() {
						App.init();
						fileUpLoad();	
					//文件上传前触发事件
				    $('[upload-file=imageUrlProduct]').bind('fileuploadsubmit', function (e, data) {
				        data.formData = { imgType:$("#status_select").val()};  //如果需要额外添加参数可以在这里添加
				    });
						//  $("#uploadimg").on('click',fileUpLoad);
						  $("#status_select").select2({placeholder: "选择状态"});
						  $("#status_select").change(function(){
							  selImg = $("#status_select").val();
						  });  
						$('#nestable2').nestable({
							maxDepth: 1
						});
						//detailFileUpLoad();

						//查看状态
						if(flag=="1"){
							$("input").attr("readonly","true");
							$(".btn").hide();
						}
						
					} 
				}
			}();
			$(function() {
				$("#header").load("../head.html");
				AddCoupon.init();
			});

		</script>
		<!-- /JAVASCRIPTS -->
	</body>
</html>